def partition(numbers, number): # DO NOT modify this line 
    list_small=[]
    list_big=[]
    list_middle=[number]
    list_final=[]
    for i in numbers:
        if i <number:
            list_small.append(i)
        else:
            list_big.append(i)
    list_final=list_small+list_middle+list_big
    numbers.clear()
    for j in list_final:
        numbers.append(j)
    return numbers.index(number)
# === DO NOT modify the code below ===
def main():
    numbers = [ eval(x) for x in input().split() ]
    x = eval(input())
    index = partition(numbers, x)
    print(" ".join(map(str,numbers)))
    print(index)
    
if __name__ == "__main__":
    main()